export default {
  namespaced: true,
  state: {
    len: Number(localStorage.getItem("pcLen")) || 0,
    record: JSON.parse(localStorage.getItem("pcRecord")) || [],
  },
  mutations: {
    setRecord(state, val) {
      state.record = val;
      localStorage.setItem("pcRecord", JSON.stringify(val));
    },
    addRecord(state, val) {
      console.log(val);
      state.record.unshift(val);
      state.len++;
      localStorage.setItem("pcRecord", JSON.stringify(state.record));
      localStorage.setItem("pcLen", state.len);
    },
  },
};
